package com.asynctm.android.socialnetwork.activity;

import twitter4j.Status;
import android.view.View;
import android.widget.TextView;

import com.asynctm.android.R;
import com.asynctm.android.common.util.DateUtil;
import com.github.droidfu.widgets.WebImageView;

/**
 * Elemento de la lista de tweets
 * 
 * @author rockdrigo
 */
public class TweetListItemViewHolder {
	
	private static final String DATE_TIME_FORMAT = "dd/MM/yyyy HH:mm:ss";

	private WebImageView imgImg;
	private TextView lblText;
	private TextView lblScreenTitle;
	private TextView lblName;
	private TextView lblDateTime;

	public TweetListItemViewHolder(View parent) {
		lblText = (TextView) parent.findViewById(R.id.lblText);
		lblScreenTitle = (TextView) parent.findViewById(R.id.lblScreenTitle);
		lblName = (TextView) parent.findViewById(R.id.lblName);
		imgImg = (WebImageView) parent.findViewById(R.id.imgImg);
		lblDateTime = (TextView) parent.findViewById(R.id.lblDateTime);
	}

	public TextView getLblText() {
		return lblText;
	}
	
	public WebImageView getImgImg() {
		return imgImg;
	}

	public TextView getLblScreenTitle() {
		return lblScreenTitle;
	}

	public TextView getLblName() {
		return lblName;
	}

	public void populate(Status status) {
		lblText.setText(status.getText());
		lblDateTime.setText( DateUtil.format(status.getCreatedAt(), DATE_TIME_FORMAT) );
		lblName.setText(status.getUser().getName());
		lblScreenTitle.setText(status.getUser().getScreenName());
		imgImg.setImageUrl(status.getUser().getProfileImageURL().toString());
		imgImg.loadImage();
	}
	
}
